home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlb20 / lib / _extends.cpp < prev    next >
Text File  |  1992-03-30  |  3KB  |  125 lines

  1. #ifndef    __M68881__
  2. # ifndef sfp004
  3. |
  4. | single float to double float conversion routine
  5. |
  6. | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  7. | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  8. |
  9. |
  10. | Revision 1.2, kub 01-90 :
  11. | added support for denormalized numbers
  12. |
  13. | Revision 1.1, kub 12-89 :
  14. | Ported over to 68k assembler
  15. |
  16. | Revision 1.0:
  17. | original 8088 code from P.S.Housel
  18.  
  19. BIAS4    =    0x7F-1
  20. BIAS8    =    0x3FF-1
  21.  
  22.     .text
  23.     .even
  24.     .globl    __extendsfdf2, ___extendsfdf2
  25.  
  26. __extendsfdf2:
  27. ___extendsfdf2:
  28.     lea    sp@(4),a0    | parameter pointer
  29.     moveml    d2-d7,sp@-    | save regs to keep norm_df happy
  30.     movel    a0@,d4        | get number
  31.     clrl    d5        | prepare double mantissa
  32.  
  33.     movew    a0@,d0        | extract exponent
  34.     movew    d0,d2        | extract sign
  35.     lsrw    #7,d0
  36.     andw    #0xff,d0    | kill sign bit (exponent is 8 bits)
  37.  
  38.     andl    #0x7fffff,d4    | remove exponent from mantissa
  39.     tstw    d0        | check for zero exponent - no leading "1"
  40.     beq    0f        | for denormalized numbers
  41.     orl    #0x800000,d4    | restore implied leading "1"
  42.     bra    1f
  43. 0:    addw    #1,d0        | "normalize" exponent
  44. 1:
  45.     addw    #BIAS8-BIAS4-3,d0    | adjust bias, account for shift
  46.     clrw    d1        | dummy rounding info
  47.  
  48.     jmp    norm_df
  49.  
  50. # else    sfp004
  51.  
  52. | single precision floating point stuff for Atari-gcc using the SFP004
  53. | developed with gas
  54. |
  55. | single float to double float conversion routine
  56. |
  57. | M. Ritzert (mjr at dmzrzu71)
  58. |
  59. | 4.10.1990
  60. |
  61. | no NAN checking implemented since the 68881 treats this situation "correct",
  62. | i.e. according to IEEE
  63.  
  64. | addresses of the 68881 data port. This choice is fastest when much data is
  65. | transferred between the two processors.
  66.  
  67. comm =     -6
  68. resp =    -16
  69. zahl =      0
  70.  
  71. | waiting loop ...
  72. |
  73. | wait:
  74. | ww:    cmpiw    #0x8900,a1@(resp)
  75. |     beq    ww
  76. | is coded directly by
  77. |    .long    0x0c688900, 0xfff067f8
  78.  
  79.     .text
  80.     .even
  81.     .globl    __extendsfdf2, ___extendsfdf2
  82.  
  83. __extendsfdf2:
  84. ___extendsfdf2:
  85.     lea    0xfffa50,a0
  86.     movew    #0x4400,a0@(comm)    | load argument to fp0
  87.     cmpiw    #0x8900,a0@(resp)    | check
  88.     movel    a7@(4),a0@        | now push arg
  89.     movew    #0x7400,a0@(comm)    | result to d0/d1
  90.     .long    0x0c688900, 0xfff067f8
  91.     movel    a0@,d0            | pop double float
  92.     movel    a0@,d1
  93.     rts
  94.  
  95. # endif    sfp004
  96. #else    __M68881__
  97.  
  98. | mjr:    provided for safety. should be never called.
  99. |
  100. | single precision floating point stuff for Atari-gcc
  101. | developed with gas
  102. |
  103. | single float to double float conversion routine
  104. |
  105. | M. Ritzert (mjr at dfg.dbp.de)
  106. |
  107. | 4.10.1990
  108. | 11.11.1991
  109. |
  110. | no NAN checking implemented since the 68881 treats this situation "correct",
  111. | i.e. according to IEEE
  112.  
  113.     .text
  114.     .even
  115.     .globl    __extendsfdf2, ___extendsfdf2
  116.  
  117. __extendsfdf2:
  118. ___extendsfdf2:
  119.     fmoves    a7@(4),fp0    | load argument to fp0
  120.     fmoved    fp0,a7@-    | read back as double
  121.     moveml    a7@+,d0-d1
  122.     rts
  123.  
  124. #endif    __M68881__
  125.